package co.fitstart.scheduler.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import co.fitstart.scheduler.persistence.GenericJdbcSupport;
import co.fitstart.scheduler.service.SatisfactionSurveyUpdateService;

@Service("satisfactionSurveyUpdateService")
public class SatisfactionSurveyUpdateServiceImpl implements SatisfactionSurveyUpdateService{

	private static final Logger logger = LoggerFactory.getLogger(SatisfactionSurveyUpdateServiceImpl.class);
	
	 @Autowired
	 private GenericJdbcSupport genericJdbcSupport;
	 
	 
	public void updateSatisfactionSurvey() {
		// TODO Auto-generated method stub

		Date now = new Date();
	        
		logger.info("start running SatisfactionSurveyJob#scanCourseRoundExpiry at {}", now);	        
		
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("today", now);
	       
		genericJdbcSupport.executeSQL("UPDATE satisfaction_survey SET is_disabled=true WHERE is_disabled=false AND end_time < :today AND fill_in_time is null",parameters );
		
	}
    
  
}
